package de.baumann.browser.adapter

import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import de.baumann.browser.OdinGlideModule
import de.baumann.browser.R
import de.baumann.browser.api.net.vo.Coin
import de.baumann.browser.utils.web3j.BalanceTask
import de.baumann.browser.utils.web3j.BalanceTask2

class OCBAdapter(var a: String) : BaseQuickAdapter<Coin, BaseViewHolder>(R.layout.item_ocb) {
    override fun convert(helper: BaseViewHolder, item: Coin) {
        helper.setText(R.id.ocbn, item.name)
        val ocbi: ImageView = helper.getView(R.id.ocbi)
        OdinGlideModule.load(mContext, item.icon, ocbi, R.drawable.shape_cover)

        val ocbv: TextView = helper.getView(R.id.ocbv)
        when (item.name.toUpperCase()) {
            "ODIN" -> {
                BalanceTask(ocbv).execute(a)
            }
            else -> {
                BalanceTask2(ocbv,item.node,a,item.contract).execute()
            }
        }
    }
}